
class TradeServiceTests extends GroovyTestCase{

    def tradeService
    void setUp(){
        ['Plumber','Carpenter'].each{ new Trade(tradeName:it).save(flush:true)}

        tradeService = new TradeService()
    }

    void testThatTradesAreFound(){
        assertEquals(2, tradeService.findOrCreateTrades('plumber, carpenter').size())
    }

    void testThatTradesAreCreatedWhenPassedIn(){
        assertEquals(1, tradeService.findOrCreateTrades('electrian').size())
        assertEquals('Electrian', Trade.findByITradeName('electrian').tradeName)
    }

}